<?php
/**
 * Created by PhpStorm.
 * User: lixy
 * Date: 2016/1/6
 * Time: 9:14
 */


use yii\helpers\Url;
use app\lib\WeixinUtils;

$web = Url::to("@web");
//获取微信js
$sign = WeixinUtils::getJs_SignPackage();
?>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta content="telephone=no" name="format-detection"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>送礼记录详情</title>
    <link rel="stylesheet" href="<?= $web ?>/css/global.css"/>
    <link rel="stylesheet" href="<?= $web ?>/css/wx/gift-send-detail.css"/>
    <script type="text/javascript" src="<?= $web ?>/js/jquery.js"></script>
	<script src="<?= $web ?>/js/wx/wx_utils.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            var w = $(window).width();

            if (w > 640) {
                w = 640;
            }
            $("body").css("font-size", w * 20 / 320);
        });

        wx.config({
            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
            appId: '<?=APPID?>', // 必填，公众号的唯一标识
            timestamp:<?=$sign['timestamp']?> , // 必填，生成签名的时间戳
            nonceStr: '<?=$sign['nonceStr']?>', // 必填，生成签名的随机串
            signature: '<?=$sign['signature']?>',// 必填，签名，见附录1
            jsApiList: jsApiList_order_share // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
        });
        wx.ready(function () {
            var orderid = $("#hidden_orderid").val();
            var url = $("#hidden_url").val() + "?id=" + orderid;
			
            wx_setShare({
				 title: '<?=$user['NICK_NAME']?>送你朵拉礼卡', // 分享标题
                desc: '点击兑换朵拉盒好礼！朵拉超越你的想象，精彩好礼随心兑换！送心意、送逼格！送礼就选朵拉盒 ', // 分享描述+orderid
                link: url // 分享链接  receive-gift
			});
        });
        function href_card_list(id) {
            //alert(id);
            id = encodeURI(id);
            window.location.href = "<?=Url::to(["wx-biz/card-detail"]);?>?isbuy=0&id=" + id;
        }
    </script>
</head>
<body>
<input type="hidden" id="hidden_orderid" value="<?= $orderid ?>"/>
<!--<input type="hidden" id="hidden_url" value="--><? //=Url::to(["wx-biz/get-card"],true)?><!--"/>-->
<input type="hidden" id="hidden_url" value="<?= Url::to(["wx-biz/gift-receive"], true) ?>"/>
<div class="main">
    <div class="gift-container">
        <div class="title-container" style="background-image: url(<?= $web ?>/img/wx/title-bg.png);">
            <div class="title-content">
                <div class="logo" style="background-image: url(<?= $web ?>/img/wx/rectangle-logo.png);"></div>
                <div class="logo-text" style="background-image: url(<?= $web ?>/img/wx/rectangle-card.png);"></div>
                <div class="title">
                    <table cellspacing="0" cellpadding="0">
                        <tr>
                            <td id="title-main"><?= $card['NAME'] ?></td>
                        </tr>
                        <tr>
                            <td id="title-desc">有效期：<?= $card['VALID_DATE_MESSAGE'] ?></td>
                        </tr>
                    </table>
                </div>
                <div class="title-right"></div>

            </div>
            <div class="bless-container">
                <div class="user-head">
                    <img src="<?= $user['HEADER_URL'] ?>"/>
                </div>
                <div class="user-bless">
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <td id="user-target"> <?= $user['NICK_NAME'] ?>：</td>
                        </tr>
                        <tr>
                            <td id="bless-text">我在朵拉盒为您选了一张朵拉礼卡，祝您万事如意。</td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="split-black"></div>
            <div class="duora-info">
                <div id="duora-num">
                    <label>共发出</label>
                    <span><?= $count ?></span>
                    <label>张朵拉卡，已被领取</label>
                    <span><?= $getcount ?></span>
                    <label>张，剩余</label>
                    <span><?= $count - $getcount ?></span>
                    <label>张未领取</label>
                </div>
            </div>
        </div>
    </div>
    <div class="btn" onclick="href_card_list('<?= $card["ID"] ?>');">查看礼品卡详情</div>
    <div class="lists">
        <?php
        foreach ($rCards as &$rCard) {
            if ($rCard['STATUS'] == 1) {
                ?>
                <div class="list-item">
                    <div id="user-head">
                        <img src="<?= $rCard['HEADER_URL'] ?>"/>
                    </div>
                    <div class="item">
                        <div class="item-name">
                            <label style="color: #5d5c5c;"><?= $rCard['NICK_NAME'] ?> &nbsp;已领取</label>
                        </div>
                    </div>
                    <div class="item-time"><?= date("m-d", strtotime($rCard['GET_DATETIME'])) ?></div>
                </div>
                <?php
            } else if ($rCard['STATUS'] == 2) {
                ?>
                <div class="list-item">
                    <div id="user-head">
                        <img src="<?= $rCard['HEADER_URL'] ?>"/>
                    </div>
                    <div class="item">
                        <div class="item-name">
                            <label style="color: #5d5c5c;"><?= $rCard['NICK_NAME'] ?>&nbsp;已兑换&nbsp;</label><label
                                style="color: #d7000f;"><?= $rCard['GOODS_NAME'] ?></label>
                        </div>
                    </div>
                    <div class="item-time"><?= date("m-d", strtotime($rCard['EXCHANGE_DATETIME'])) ?></div>

                </div>
                <?php
            } else if ($rCard['STATUS'] == 5) {
                ?>
                <div class="list-item">
                    <div id="user-head">
                        <img src="<?= $rCard['HEADER_URL'] ?>"/>
                    </div>
                    <div class="item">
                        <div class="item-name">
                            <label style="color: #5d5c5c;"><?= $rCard['NICK_NAME'] ?>&nbsp;已兑换&nbsp;</label><label
                                style="color: #d7000f;"><?= $rCard['DORACOIN'] ?></label>
                        </div>
                    </div>
                    <div class="item-time"><?= date("m-d", strtotime($rCard['EXCHANGE_DATETIME'])) ?></div>

                </div>
                <?php
            }
        }
        ?>
    </div>

</div>
</body>
</html>

